<template>
    
    <layout> 
        <el-card class="box-card">
 



<p>
       
        <el-descriptions title="广西标准化协会团体标准发布统计表" :column="1" border>

        </el-descriptions>
    </p>
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="标准名称">
                <span>{{ list.id }}</span>
            </el-form-item>
            <el-form-item label="标准编号" prop="pid">
                <el-input v-model="ruleForm.pid"></el-input>
            </el-form-item>
            <el-form-item label="标准名称" prop="name">
                <el-input v-model="ruleForm.name"></el-input>
            </el-form-item>
            <el-form-item label="发布日期" >
             
                <span>{{ moment(list.addTime).format("YYYY-MM-DD hh:mm:ss") }}</span>
          
            </el-form-item>
            <el-form-item label="实施日期">
                <span>{{ moment(list.updateTime).format("YYYY-MM-DD hh:mm:ss") }}</span>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm('ruleForm')">立即修改</el-button>
                <el-button @click="resetForm">返回</el-button>
            </el-form-item>
        </el-form>

    </el-card>
    </layout>
</template>

<script>
import Layout from "@/components/Layout.vue"
import axios from "axios";
import moment from 'moment'
export default {
    data() {
        return {

            ruleForm: {
                pid: "",
                name: ''
            },
            rules: {
                pid: [
                    { required: true, message: '请输入标准编号', trigger: 'blur' },

                ],
                name: [
                    { required: true, message: '请输入标准名称', trigger: 'blur' },

                ],
            },
            list: []
        }
    },
    components: {
        Layout
    },
    created() {
        const { cid } = this.$route.params

        console.log(cid)
        axios({
            url: "http://43.143.166.235:8090/chaxun/select?id=" + cid
        }).then(res => {
            console.log(res)
            this.list = res.data.data
            this.ruleForm = res.data.data
        })
    },
    methods: {
        moment,
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    axios({
                        url: "http://43.143.166.235:8090/chaxun/update",
                        method: "post",
                        data: {
                            "id": this.ruleForm.id,
                            "pid": this.ruleForm.pid,
                            "name": this.ruleForm.name
                        }
                    }).then(res => {
                        console.log(res)
                    })
                    alert('修改成功!');
                    this.$router.push({
                        name: 'booklist'
                    })
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        resetForm() {
            this.$router.push({
                name: 'booklist'
            })
        }
    }
}
</script>
<style></style>